package com.project.bookstore.category.controller;

import com.project.bookstore.category.pojo.CategoryIndexVO;
import com.project.bookstore.category.pojo.CategoryRelatedVO;
import com.project.bookstore.category.service.CategoryService;
import com.project.bookstore.common.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/category")
public class CategoryController {
    @Autowired
    private CategoryService service;

    @GetMapping("/index")
    public CommonResult<List<CategoryIndexVO>> getCategoryForIndex(){
        return service.getCategoryForIndex();
    }

    @GetMapping("/related/{classifyId}")
    public CommonResult<List<CategoryRelatedVO>> getRelatedClassify(
            @PathVariable Long classifyId){
        return service.getRelatedClassify(classifyId);
    }
}
